<?php

namespace app\admin\model;

use app\common\library\Iden;
use think\Db;
use think\Model;

class AdminFollow extends Model
{
    // 表名
    protected $table = 'admin_follow';//关注表
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'ctime';
    protected $updateTime = false;
    protected $deleteTime = false;


    /*
     * 是否被关注
     */
    public function isfollow($opid,$fid){

        if(empty($opid) || empty($fid)){
            return false;
        }

        $map['operate_uid'] = $opid;
        $map['follow_uid'] = $fid;
        $cnt = Db::name('admin_follow')->where($map)->count();
        if($cnt > 0){
            return 1;
        }
        else{
            return 0;

        }
    }

    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'follow_uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}



